package com.sunkyc.controller.system;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.sunkyc.commons.annotation.ReqLog;
import com.sunkyc.commons.entity.R;
import com.sunkyc.framework.system.entity.SysDictType;
import com.sunkyc.framework.system.service.SysDictTypeService;
import com.sunkyc.commons.entity.PageQueryVo;
import io.swagger.annotations.Api;
import com.sunkyc.commons.entity.TablePageData;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 字典类型表 前端控制器
 * </p>
 *
 * @author sunkyc
 * @since 2022-05-31
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sysDictType")
@Api(value = "字典类型前端控制器", tags = {"字典类型管理"})
public class SysDictTypeController {
    private final SysDictTypeService baseService;


    @PostMapping
    @ApiOperation("字典类型添加")
    @SaCheckPermission("system-dict-type-add")
    @ReqLog
    public R<Void> add(@RequestBody @Validated SysDictType sysDictType) {
        return R.result(baseService.addDictType(sysDictType));
    }

    @PutMapping
    @ApiOperation("数据字典类型修改")
    @SaCheckPermission("system-dict-type-update")
    @ReqLog
    public R<Void> update(@RequestBody @Validated SysDictType sysDictType) {
        return R.result(baseService.updateDictType(sysDictType));
    }


    @GetMapping("list")
    @ApiOperation("数据字典类型列表")
    @SaCheckPermission("system-dict-type-query")
    public R<TablePageData<SysDictType>> queryList(PageQueryVo pageQueryVo, SysDictType sysDictType){
        return R.ok(baseService.queryList(pageQueryVo, sysDictType));
    }


    @DeleteMapping("/{dictIds}")
    @ApiOperation("数据字典类型删除")
    @SaCheckPermission("system-dict-type-delete")
    @ReqLog
    public R<Void> batchDelete(@PathVariable("dictIds") Long[] dictIds){
        return R.result(baseService.batchDelete(dictIds));
    }


}
